﻿
@{
    ViewBag.Title = "提现列表";
}
@section CSS{

}
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            提现
            <small>列表</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li><a href="#">财务管理</a></li>
            <li class="active">提现列表</li>
        </ol>
    </section>
    <section class="content" style="min-height:100px;">
        <div class="row">
            <div class="col-md-6 col-sm-6 col-xs-12">
                <div class="info-box">
                    <span class="info-box-icon bg-green "><i class="ion ion-social-yen-outline"></i></span>

                    <div class="info-box-content">
                        <span class="info-box-text">可提现余额</span>
                        <span class="info-box-number">@ViewBag.Balance.ToString("f2")<small>元</small></span>
                        <a href="javascript:void(0);" onclick="admin_add('申请提现','/Finance/AddWithdrawal',500,400)">申请提现</a>
                    </div>
                    <!-- /.info-box-content -->
                </div>
                <!-- /.info-box -->
            </div>
            <!-- /.col -->
            <div class="col-md-3 col-sm-6 col-xs-12">
                <div class="info-box">
                    <span class="info-box-icon bg-teal"><i class="ion ion-social-buffer-outline"></i></span>
                    <div class="info-box-content">
                        <span class="info-box-text">累计提现</span>
                        <span class="info-box-number">￥@ViewBag.Withdrawal.ToString("f2")<small>元</small></span>
                    </div>
                    <!-- /.info-box-content -->
                </div>
                <!-- /.info-box -->
            </div>
            <div class="col-md-3 col-sm-6 col-xs-12">
                <div class="info-box">
                    <span class="info-box-icon bg-yellow"><i class="ion ion-ios-timer-outline"></i></span>
                    <div class="info-box-content">
                        <span class="info-box-text">提现中</span>
                        <span class="info-box-number">@ViewBag.Withdrawaling.ToString("f2")<small>元</small></span>
                    </div>
                    <!-- /.info-box-content -->
                </div>
                <!-- /.info-box -->
            </div>
            <!-- /.col -->
            <!-- fix for small devices only -->
            <div class="clearfix visible-sm-block"></div>
        </div>
    </section>
    <section style="display:none;">
            <div class="col-xs-12">
                <div class="box box-primary ">
                    <!-- form start -->
                    <form class="form-horizontal">
                        @*<div class="box-body">
                            <div class="form-group">
                                <label for="status" class="col-sm-2 control-label">提现状态</label>
                                <div class="col-sm-2">
                                    <select class="form-control" id="status">
                                        <option value="-1">-请选择状态-</option>
                                        <option value="1">待审核</option>
                                        <option value="2">已取消</option>
                                        <option value="3">已通过</option>
                                        <option value="4">已拒绝</option>
                                    </select>
                                </div>
                                <label for="code" class="col-sm-2 control-label">申请编号</label>
                                <div class="col-sm-2">
                                    <input type="text" class="form-control" id="code" placeholder="申请编号">
                                </div>
                            </div>
                        </div>
                        <div class="box-body">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">申请日期</label>
                                <div class="col-sm-2">
                                    <div class="input-group date">
                                        <div class="input-group-addon">
                                            <i class="fa fa-calendar"></i>
                                        </div>
                                        <input type="text" class="form-control pull-right" id="startTime">
                                    </div>
                                </div>
                                <label style="float:left;"> - </label>

                                <div class="col-sm-2">
                                    <div class="input-group date">
                                        <div class="input-group-addon">
                                            <i class="fa fa-calendar"></i>
                                        </div>
                                        <input type="text" class="form-control pull-right" id="endTime">
                                    </div>
                                </div>
                            </div>
                        </div>*@
                        <!-- /.box-body -->
                        <div class="box-footer ">
                            @*<button type="button" class="btn btn-primary btn-search center-block" id="btnSearch"><i class="fa fa-search"></i> 查询</button>*@
                            @*<button type="button" class="btn btn-info" id="btnAdd" onclick="admin_add('申请提现','/Finance/AddWithdrawal',500,400)"><i class="fa fa-plus"></i> 申请提现</button>*@
                            @*<button type="button" class="btn btn-danger" id="btnDelMul"><i class="fa fa-remove"></i> 批量删除</button>
            <button type="button" class="btn btn-info" id="btnAdd"><i class="fa fa-plus"></i> 添加</button>
            <button type="button" class="btn btn-success" id="btnExport"><i class="fa fa-download"></i> 导出Excel</button>*@
                        </div>
                        <!-- /.box-footer -->
                    </form>
                </div>
            </div>
        </section>

        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-xs-12">
                    <div class="box">
                        <div class="box-header my_search">
                            <select style="width:150px;" class="form-control" id="status">
                                <option value="-1">- 提现状态 -</option>
                                <option value="-1">-请选择状态-</option>
                                <option value="1">待审核</option>
                                <option value="3">已通过</option>
                                <option value="4">已拒绝</option>
                            </select>
                            <input type="text" style="width:120px;" class="form-control pull-left" id="startTime" placeholder="申请日期-起">
                            <span style="line-height:30px;">至</span>
                            <input type="text" style="width:120px;" class="form-control pull-left" id="endTime" placeholder="申请日期-止">
                            <input type="text" style="width:180px;" class="form-control" id="code" placeholder="流水编号">
                            <button type="button" class="btn btn-default " id="btnSearch"><i class="fa fa-search"></i> 搜索</button>
                        </div>
                        <div class="box-body">
                            <table id="DataList" class="table table-bordered table-striped table-hover ">
                                <thead>
                                    <tr>
                                        <th>提现流水</th>
                                        <th>提现金额(元)</th>
                                        <th>手续费(费率)</th>
                                        <th>提现账号</th>
                                        <th>申请时间</th>
                                        <th>状态</th>
                                        <th width="200">&nbsp;</th>
                                        <th >查看</th>
                                    </tr>
                                </thead>
                                <tbody> </tbody>
                            </table>
                        </div>
                        <!-- /.box-body -->
                    </div>
                    <!-- /.box -->
                </div>
                <!-- /.col -->
            </div>
            <!-- /.row -->
        </section>
        <!-- /.content -->
</div>
<!-- /.content-wrapper -->
@section JS{
<script>
        $(function () {
            //初始化表格
            GenerateTable();
            //鼠标移动到该行变色
            $('.table-hover tbody').on('click', 'tr', function () {
                if ($(this).hasClass('selected')) {
                    $(this).removeClass('selected');
                }
                else {
                    u_table.$('tr.selected').removeClass('selected');
                    $(this).addClass('selected');
                }
            });
            //搜索事件
            $("#btnSearch").on("click", function () {
                var classSelect = $("#classSelect").val();
                var datemin = $('#startTime').val();
                var datemax = $("#endTime").val();
                if ((datemin == null && datemax != null) || (datemin != null && datemax == null)) {
                    layer.msg('请把时间填充完整!', { icon: 1, time: 1000 });
                }
                else {
                    u_table.fnDestroy();
                    GenerateTable();
                }
            });

            $('#startTime').datepicker({
                autoclose: true
            });

            $('#endTime').datepicker({
                autoclose: true
            });
        });
        //生成表格
        function GenerateTable() {
            u_table = $('#DataList').dataTable({
                "lengthChange": false,
                "searching": false,
                "ordering": false,
                "iDisplayLength": 10,
                "bProcessing": true,
                "bServerSide": true,
                "fnServerParams": function (aoData) {
                    var status = $("#status").val();
                    var datemin = $('#startTime').val();
                    var datemax = $("#endTime").val();
                    var code = $("#code").val();
                    aoData.push(
                        { "name": "dateMin", "value": datemin },
                        { "name": "dateMax", "value": datemax },
                        { "name": "code", "value": code },
                        { "name": "status", "value": status }
                    );
                },
                "sAjaxSource": "/finance/withdrawallist",
                "aoColumns": [
                   //{ "mDataProp": 'id' },
                    { "mDataProp": 'withdrawal_no' },
                    { "mDataProp": 'money' },
                    {
                        "mDataProp": 'fee', "mRender": function (data, type, full) {
                            return data + " (" + full.fee_rate + "%)";
                        }
                    },
                    {
                        "mDataProp": 'bank_name', "mRender": function (data, type, full) {
                            return data + "-" + (full.account_holder.length > 1 ? (full.account_holder.substr(0, 1)+"**") : full.account_holder) + "<br/>" + FormatBankNumber(full.bank_cardno);
                        }
                    },
                    {
                        "mDataProp": 'add_time', "mRender": function (data, type, full) {
                            return moment(data).format("YYYY-MM-DD HH:mm:ss");
                        }
                    },
                    {
                        "mDataProp": 'status', "mRender": function (data, type, full) {
                            return data == 1 ? "<span style='color:orange'>提现中</span>" : (data == 3 ? "<span style='color:green'>成功</span>" : "<span style='color:red'>拒绝</span>");
                        }
                    },
                    {
                        "mDataProp": 'handling_time', "mRender": function (data, type, full) {
                            if (full.status == 4) {
                                return (data == null || data == "" ? "" : (moment(data).format("YYYY-MM-DD HH:mm:ss") + "<br/>")) + full.remark;
                            }
                            return "";
                        }
                    }
                    , {
                        "mDataProp": 'id', "mRender": function (data, type, full) {
                            return "<a href='javascript:void(0);' onclick='admin_edit(\"提现详情\",\"/Finance/WithdrawalDetails\","+ data + ",500,600)'  title='详情'>详情</a>";
                        }
                    }
                ]
            });
        }

        /*增加*/
        function admin_add(title, url, w, h) {
            layer_show(title, url, "", w, h);
        };

        /*编辑*/
        function admin_edit(title, url, id, w, h) {
            layer_show(title, url, id, w, h);
        };
</script>
}
